// api/familynews.js
const { get, post, put, delete: del } = require('./request');

// 获取家族动态列表
function getNewsList(params = {}) {
  return get('/family-news', params);
}

// 获取动态详情
function getNewsDetail(id) {
  return get(`/family-news/${id}`);
}

// 点赞动态
function likeNews(id) {
  return post(`/family-news/${id}/like`);
}

// 取消点赞
function unlikeNews(id) {
  return del(`/family-news/${id}/like`);
}

// 增加浏览量
function increaseViewCount(id) {
  return post(`/family-news/${id}/view`);
}

// 获取动态点赞详情
function getNewsLikes(newsIds) {
  const idsParam = Array.isArray(newsIds) ? newsIds.join(',') : newsIds;
  return get(`/family-news/likes?newsIds=${idsParam}`);
}

// 获取用户对动态的点赞状态
function getUserLikes(newsIds) {
  const idsParam = Array.isArray(newsIds) ? newsIds.join(',') : newsIds;
  return get(`/family-news/user-likes?newsIds=${idsParam}`);
}

module.exports = {
  getNewsList,
  getNewsDetail,
  likeNews,
  unlikeNews,
  increaseViewCount,
  getNewsLikes,
  getUserLikes
}; 